//
//  LZLHeaderViewCell.swift
//  swiftDemo
//
//  Created by luozhilin on 2018/9/14.
//  Copyright © 2018年 luozhilin. All rights reserved.
//

import UIKit

class LZLHeaderViewCell: UICollectionViewCell {
    
    private lazy var nameLabel:UILabel = {
        let label = UILabel()
        label.textAlignment = .center
        label.font = UIFont.systemFont(ofSize: 14)
        label.textColor = UIColor.black
        return label
    }()
    
    private lazy var imageView:UIImageView = {
        
        let imageView = UIImageView()
        
        return imageView
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.contentView.addSubview(imageView)
        
        imageView.snp.makeConstraints { (make) in
            make.height.width.equalTo(45)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(10)
        }
        
        self.contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.centerX.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom).offset(10)
            make.height.equalTo(20)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // 对外部暴露的属性
    var dataString:String? {
        didSet {
            self.nameLabel.text = dataString
            self.imageView.image = UIImage(named: dataString!)
        }
    }
}
